package com.ayou.eggguard.farm.mapper;

import com.ayou.eggguard.farm.pojo.Trade;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TradeMapper {
    List<Trade> getTrades(String orderNumber);

    @Insert("insert into trade_record(buyer_name, buyer_contact, buyer_address, deposit, order_date, delivery_date, delivery_address, consignee, checkout_time, checkout_way, order_number) " +
            "values(#{buyerName},#{buyerContact},#{buyerAddress},#{deposit},#{orderDate},#{deliveryDate},#{deliveryAddress},#{consignee},#{checkoutTime},#{checkoutWay},#{orderNumber})")
    void add(Trade trade);

    @Update("update trade_record set buyer_name=#{buyerName},buyer_contact=#{buyerContact},buyer_address=#{buyerAddress}," +
            "deposit=#{deposit},order_date=#{orderDate},delivery_date=#{deliveryDate},delivery_address=#{deliveryAddress}," +
            "consignee=#{consignee},checkout_time=#{checkoutTime},checkout_way=#{checkoutWay},order_number=#{orderNumber} " +
            "where trade_id=#{tradeId}")
    void update(Trade trade);

    @Delete("delete from trade_record where trade_id=#{tradeId}")
    void delete(Integer tradeId);
}
